﻿
Partial Class store_UCVideo
    Inherits System.Web.UI.UserControl

    Public Sub Display(p As CProduct, list As CProductList)
        If Me.Parent.Controls.Count Mod 2 = 1 Then row.Attributes.Add("class", "alt_row")

        lnkDate.Text = p.ProductCreated.ToString("d-MMM-yy")
        lnkDate.ToolTip = p.DateString()
        lnkDate.NavigateUrl = CSitemap.Decide(p)

        litTitle.Text = CUtilities.Truncate(p.ProductName, 50)
        With lnkTitle
            .NavigateUrl = CSitemap.Decide(p) & "#video"
            .ToolTip = String.Concat(p.ProductNameAndContents, vbCrLf, p.ProductDescriptionOrParent)
        End With
        If p.IsSet Then
            litTitle.Text = String.Concat(CUtilities.Truncate(p.ProductName, 60).Replace("(", "").Replace(")", ""), " (", p.Contents, ")")
            lnkVimeo.Font.Bold = True
            lnkYouTube.Font.Bold = True
        Else
            lnkTitle.Font.Bold = False
        End If

        If p.IsEnglish Then
            lnkNameChineseSimplified.Visible = False
        Else
            lnkNameChineseSimplified.Text = p.ProductNameChineseSimplified
            lnkNameChineseSimplified.NavigateUrl = lnkTitle.NavigateUrl
            lnkNameChineseSimplified.ToolTip = p.ProductDescriptionChineseSimplifiedOrParent
            lnkNameChineseSimplified.Font.Bold = p.IsSet
        End If


        With lnkSpeaker
            .Text = CUtilities.Truncate(p.SpeakerName, 12)
            .NavigateUrl = CSitemap.Video(Nothing, p.ProductSpeakerId)
        End With

        With lnkVimeo
            If p.HasVimeo Then
                .Text = p.ProductVimeoId
                .ToolTip = "Watch on Vimeo: " & p.ProductName
                .NavigateUrl = p.VideoUrl_Vimeo
            ElseIf p.HasVimeoChannel Then
                .Text = CUtilities.Truncate(p.ProductVimeoChannelIdOrParent, 15)
                .ToolTip = "Vimeo Channel: " & p.ProductName
                .NavigateUrl = p.VideoUrl_VimeoChannel
            Else
                .Visible = False
            End If
        End With

        With lnkYouTube
            If p.HasYouTube Then
                .Text = p.ProductYouTubeId
                .NavigateUrl = p.VideoUrl_YouTube
                .ToolTip = "Watch on YouTube: " & p.ProductName
            ElseIf p.HasYouTubePlaylist Then
                .ToolTip = "YouTube Playlist: " & p.ProductName
                .Text = CUtilities.Truncate(p.ProductYouTubePlaylistIdOrParent, 10)
                .NavigateUrl = p.VideoUrl_YouTubePlaylist
            Else
                .Visible = False
            End If
        End With

    End Sub

End Class